package com.atwisdom.star.core.bsl.event;

import com.alibaba.fastjson.JSONArray;
import com.atwisdom.star.common.vo.JsonResult;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.common.vo.StatusCode;

public class EventHandler {
  private EventExecuteBody globalState;
  private EventExecuteBody params;
  private EventExecuteBody globalScalar;
  private String condition;
  private JSONArray service;
  private EventExecuteBody back;

  public EventHandler(){


  }

  private void init(){


  }

  /**
   * 构建params参数
   * @param params
   */
  private void buildParams(JSONArray params){


  }

  /**
   * 计算事件执行条件
   * @return
   */
  private boolean calcCondition(){

    return false;
  }

  /**
   * 执行事件
   * @return
   */
  private ResultInfo<?> execute(){
    boolean flag = calcCondition();
    if(flag){



    }else{
      return JsonResult.error(StatusCode.RUN_ERROR.getCode(),"条件不满足，事件执行失败");
    }
    return processBack();
  }

  /**
   * 处理返回结果
   *
   * @return 返回数据
   */
  private ResultInfo<?> processBack() {

    return JsonResult.success(StatusCode.SUCCESS);
  }
}
